package domain.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

public class Competency implements Serializable {
	private static final long serialVersionUID = 5984821456274020707L;

	public static final int ROOT_ID = -1;
	public static final int NEW_ID = 0;

	private int id;
	private Integer parentID;
	private String name;
	private String description;
	private boolean isGroup;
	private int organizationID;
	private List<Competency> childs;

	public Competency(int id, String name) {
		this.id = id;
		this.name = name;
		childs = new ArrayList<Competency>();
	}

	public Competency() {
		this(NEW_ID, StringUtils.EMPTY);
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Integer getParentID() {
		return parentID;
	}

	public void setParentID(Integer parentID) {
		this.parentID = parentID;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public boolean getIsGroup() {
		return isGroup;
	}

	public void setIsGroup(boolean isGroup) {
		this.isGroup = isGroup;
	}

	public int getOrganizationID() {
		return organizationID;
	}

	public void setOrganizationID(int organizationID) {
		this.organizationID = organizationID;
	}

	public List<Competency> getChilds() {
		return childs;
	}

	public void setChilds(List<Competency> childs) {
		this.childs = childs;
	}

	public void addChild(Competency c) {
		if (c == null) {
			return;
		}

		childs.add(c);
	}
	
	public boolean isNew(){
		return id == NEW_ID;
	}

	@Override
	public String toString() {
		return String.format("[%s] %s. %s", "Competency", id, name);
	}
}
